package util

import (
    "os"
    "path"
)

func GetRoot() (root string) {
    cmd := os.Args[0]
    if path.IsAbs(cmd) {
        root = path.Dir(cmd)
    } else {
        wd, _ := os.Getwd()
        root = path.Dir(path.Join(wd, cmd))
    }
    return
}

func GetFile(file string) string {
    if path.IsAbs(file) {
        return file
    }

    return path.Join(GetRoot(), file)
}
